<?php
$this->menu=array(
    array('label'=>Yii::t('site','Item'),'items'=>array(
        array('label'=>Yii::t('site','Update Project'), 'url'=>array('update', 'id'=>$_GET['projectId'])),
        array('label'=>Yii::t('site','View Project'), 'url'=>array('view','id'=>$_GET['projectId'])),
    )),
    array('label'=>Yii::t('site','Reports'),'items'=>array(
        array('label'=>Yii::t('site','Milestones/Priorities'), 'url'=>array('crosstab', 'type'=>'milestones/priorities','projectId'=>$_GET['projectId']),'visible'=>$_GET['type']<>'milestones/priorities'),
        array('label'=>Yii::t('site','Owners/Milestones'), 'url'=>array('crosstab', 'type'=>'owners/milestones','projectId'=>$_GET['projectId']),'visible'=>$_GET['type']<>'owners/milestones'),
    )),
    array('label'=>Yii::t('site','All Items'),'items'=>array(
        array('label'=>Yii::t('site','Create New Project'), 'url'=>array('create')),
        array('label'=>Yii::t('site','Manage Projects'), 'url'=>array('admin')),
    )),
);
?>

<?php if($type=='milestones/priorities') : ?>

<h1><?php echo CHtml::encode(Yii::t('site','Milestones & Priorities')); ?></h1>
<?php $this->widget('application.components.crosstab',
    array(
        'row'=>'m.name',
        'rowLabel'=>Yii::t('site','Milestones'),
        'column' => "ELT(i.priority, '".'1 - '.Yii::t('site','High')."', '".'2 - '.Yii::t('site','Medium')."', '".'3 - '.Yii::t('site','Low')."')",
        'columnLabel' => Yii::t('site','Priority'),
        'cells' => 'COUNT(i.id)',
        'cellsLabel' => Yii::t('site','Count Issues'),
        'cellsLink'=>array('/issue/admin','crosstab'=>'milestones/priorities','Issue[projectId]'=>$_GET['projectId']),
        'from'=>'Milestone m',
        'leftJoins'=>array(array('Issue i','m.id=i.milestoneId')),
        'where'=>"m.projectId=".$_GET['projectId']." AND i.issueStatus IN('swIssue/new','swIssue/accepted','swIssue/started')",
    )
); ?>

<?php elseif($type=='owners/milestones') : ?>

<h1><?php echo CHtml::encode(Yii::t('site','Owners & Milestones')); ?></h1>
<?php $this->widget('application.components.crosstab',
    array(
        'row'=>"CONCAT(o.firstName,' ',o.lastName)",
        'rowLabel'=>Yii::t('site','Owner'),
        'column' => "m.name",
        'columnLabel' => Yii::t('site','Milestones'),
        'cells' => 'COUNT(i.id)',
        'cellsLabel' => Yii::t('site','Count Issues'),
        'cellsLink'=>array('/issue/admin','crosstab'=>'owners/milestones','Issue[projectId]'=>$_GET['projectId']),
        'from'=>'User o',
        'leftJoins'=>array(array('Issue i','o.id=i.ownerId'),array('Milestone m','i.milestoneId=m.id')),
        'where'=>"m.projectId=".$_GET['projectId']." AND i.issueStatus IN('swIssue/new','swIssue/accepted','swIssue/started')",
    )
); ?>

<?php else : ?>
    <h1><?php echo CHtml::encode(Yii::t('site','Project Reports')); ?></h1>
<p><?php echo CHtml::encode(Yii::t('site','Unsupported report type: {reportType}',array('{reportType}'=>$type))); ?></p>
<?php endif; ?>
